package com.sun.decrypt;

import com.sun.decrypt.utils.MessageDigestUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

import java.io.UnsupportedEncodingException;

public class Sha256Test {
    @Test
    public void sha256() throws UnsupportedEncodingException {
        String str = "哈啊哈";
        String algorithm = "SHA-256";
        String hex = MessageDigestUtils.doDigest(str, algorithm);
        System.out.println(hex);
        //codec来实现sha256
        String sha256Hex = DigestUtils.sha256Hex(str.getBytes("utf-8"));
        System.out.println(sha256Hex);
    }
}
